/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.sysmo.server.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import org.sysmo.server.SysmoServer;

/**
 *
 * @author Derek
 */
public class DoDeleteWarningAction extends org.apache.struts.action.Action {
    
    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        SysmoServer server = (SysmoServer)getServlet().getServletContext().getAttribute("sysmoServer");
        int wid = Integer.parseInt(request.getParameter("wid"));
        int re = Integer.parseInt(request.getParameter("re"));
        String reid = request.getParameter("reid");
        server.getWarning(wid).remove();
        switch (re) {
            case 0: return new ActionForward("/AllNodes.do#warning", true);
            case 1: return new ActionForward("/Node.do?nid=" + reid + "#warning", true);
            case 2: return new ActionForward("/Item.do?iid=" + reid + "#warning", true);
            case 3: return new ActionForward("/Graph.do?gid=" + reid + "#warning", true);
            case 4: return new ActionForward("/EditGraph.do?gid=" + reid + "#warning", true);
        }
        return mapping.findForward("success");
    }
}
